package com.leetcode.weekly.contest.no235th;

import java.util.StringJoiner;

/**
 * @author 覃国强
 * @date 2021-04-04 10:59
 */
public class A01_截断句子 {

  static
  class Solution {
    public String truncateSentence(String s, int k) {
      String[] split = s.split(" ");
      StringJoiner sj = new StringJoiner(" ");
      for (int i = 0; i < split.length && i < k; ++i) {
        sj.add(split[i]);
      }
      return sj.toString();
    }
  }

}
